package com.yyds.controller;

import com.yyds.common.R;
import com.yyds.pojo.VaccineStatus;
import com.yyds.service.PersonResidentVoService;
import com.yyds.service.VaccineStatusService;
import com.yyds.vo.EchartPieVo;
import com.yyds.vo.StatusInfoVo;
import com.yyds.vo.VaccineStatusVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/vaccine/status")
public class VaccineStatusController {

    @Autowired
    @Qualifier("personResidentVoService")
    private PersonResidentVoService personResidentVoService;

    @Autowired
    @Qualifier("vaccineStatusService")
    private VaccineStatusService vaccineStatusService;

    //添加居民状态信息
    @RequestMapping("/insertStatus")
    public R insertVaccineStatusController(VaccineStatusVo vo) {
        Integer i = vaccineStatusService.insertVaccineStatusService(vo);
        return i > 0 ? R.ok() : R.error();
    }

    //删除居民状态信息
    @RequestMapping("/deleteStatus")
    public R deleteVaccineStatusController(Integer status_id) {
        Integer i = vaccineStatusService.deleteVaccineStatusService(status_id);
        return i > 0 ? R.ok() : R.error();
    }

    //删除部分居民状态信息
    @RequestMapping("/deleteAllStatus")
    public R ddeleteAllVaccineStatusController(String str) {
        Integer i = vaccineStatusService.deleteAllVaccineStatusService(str);
        return i > 0 ? R.ok() : R.error();
    }

    //修改居民状态信息
    @RequestMapping("/updateStatus")
    public R updateVaccineStatusController(VaccineStatusVo vo) {
        Integer i = vaccineStatusService.updateVaccineStatusService(vo);
        return i > 0 ? R.ok() : R.error();
    }

    //查询全部人员姓名
    // queryResidentName
    @RequestMapping("/queryResidentName")
    public R queryResnidentNameController() {
        List<String> list = personResidentVoService.queryResidentNameService();
        return R.ok().data("residentName", list);
    }

    //查询全部居民状态
    @RequestMapping("/queryStatusStatusEchartPie")
    public R queryStatusStatusController() {
        List<EchartPieVo> list = vaccineStatusService.queryStatusStatusService();
        return R.ok().data("pie2", list);
    }

    @RequestMapping("/queryStatusStatusInfo")
    public R queryStatusStatusInfoController() {
        List<StatusInfoVo> statusInfoVos = vaccineStatusService.queryStatusInfoVoService();
        System.out.println("queryStatusStatusInfoController statusInfoVos = " + statusInfoVos);
        return R.ok().data("info", statusInfoVos);
    }


}
